﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZX.Web.UI.Controls;
using System.Data;
using System.Text;
using ZX.CRM.Bussiness;

namespace ZX.WebApp.DeskTop.DeskTopItem
{
    public partial class CourseDeliveryReport : BasePage
    {
        BCrmReport BReport = new BCrmReport();
        protected void Page_Load(object sender, EventArgs e)
        {
            string strPowerType = this.GetStringFromQueryString("PowerType", "");
            if (strPowerType == "")
            {
                strPowerType = "0";
            }
            string strDateType = this.GetStringFromQueryString("DateType", "");
            if (strDateType == "")
            {
                strDateType = "0";
            }
            LoadData(int.Parse(strPowerType), int.Parse(strDateType));
        }
        private void LoadData(int PowerType, int DataType)
        {
            var htmlTemp = "";
            htmlTemp += "<div style='width:100%;height:90%;overflow:auto;'><table class='tableContent' cellspacing='0'>";
            htmlTemp += "<tr>";
            htmlTemp += "    <th style='width:35%;border-left:1px solid #C1DAD7;'>课程名称</th>";
            htmlTemp += "    <th style='width:15%;'>实际交付家数</th>";
            htmlTemp += "    <th style='width:15%;'>实际交付人数</th>";
            htmlTemp += "    <th style='width:12%;'>待交付家数</th>";
            htmlTemp += "    <th style='width:13%;'>待交付人数</th>";
            htmlTemp += " </tr>";

            StringBuilder sb = new StringBuilder();
            DataTable dt = BReport.ReturnCourseDeliveryReport(this.UserId.ToString(), PowerType, DataType);
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    htmlTemp += "<tr><td style='border-left:1px solid #C1DAD7;'>" + row["CouseName"].ToString() + "</td>";
                    htmlTemp += "<td>" + row["CustomerCount"].ToString() + "</td>";
                    htmlTemp += "<td>" + row["RenShuCount"].ToString() + "</td>";
                    htmlTemp += "<td>" + row["UnCustomerCount"].ToString() + "</td>";
                    htmlTemp += "<td>" + row["UnAmount"].ToString() + "</td>";
                    htmlTemp += " </tr>";
                }
            }
            else
            {
                htmlTemp += "<tr><td colspan='5' style='border-left:1px solid #C1DAD7;'>没有数据...</td></tr>";
            }
            htmlTemp += " </table></div>";

            Response.Clear();
            Response.Write(htmlTemp);
            Response.End();
        }
    }
}